<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图书管理系统</title>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- ico 图标-->
    <link rel="shortcut icon" href="../images/favicon.ico" />
    <!-- css 文件-->
    <link rel="stylesheet" href="../css/reset.css" >
    <link rel="stylesheet" href="../css/index.css" />
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入element-ui组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <!-- axios在线地址 -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <el-container>
            <el-header class="header-container">
                <h2>图书管理系统</h2>
                <span class="userName">{{userName}}</span>
                <el-button class="logout" type="primary" @click="loginout">退出</el-button>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <el-menu>
                        <el-submenu v-for="menu in menuList" :index="menu.path">
                            <template slot="title">
                                <i class="fa" :class="menu.icon"></i>
                                {{menu.title}}
                            </template>
                            <template v-for="child in menu.children">
                                <el-menu-item :index="child.path">
                                    <a :href="child.linkUrl" target="right">{{child.title}}</a>
                                </el-menu-item>
                            </template>
                        </el-submenu>
                    </el-menu>
                </el-aside>
                <el-container>
                       <iframe name="right" class="el-main" src="/backend/page/welcome.html" width="100%" height="580px" frameborder="0"></iframe>
                    <el-footer>Footer</el-footer>
                </el-container>
            </el-container>
        </el-container>
    </div>
<script>

    new Vue({
        el: '#app',
        data:{
            tableData: [],
            userName: '',
            menuList:[
                {
                    "path" : "1",
                    "title":"图书管理",
                    "icon" : 'fa-dashboard',
                    "children" : [
                        {
                            "path":"/1-1",
                            "title":"图书列表",
                            "linkUrl":"BookList.html",
                            "children":[]
                        },
                        {
                            "path":"/1-2",
                            "title":"分类列表",
                            "linkUrl":"classification.html",
                            "children":[]
                        }
                    ]

                },
                {
                    "path" : "2",
                    "title":"人员管理",
                    "icon" : 'fa-dashboard',
                    "children" : [
                        {
                            "path":"/2-2",
                            "title":"修改信息",
                            "linkUrl":"selectList.html",
                            "children":[]
                        }
                    ]
                },
                {
                    "path" : "3",
                    "title":"会员管理",
                    "icon" : 'fa-dashboard',
                    "children" : [
                        {
                            "path":"/3-1",
                            "title":"会员档案",
                            "linkUrl":"member.html",
                            "children":[]
                        },
                        {
                            "path":"/3-2",
                            "title":"会员类型",
                            "linkUrl":"memberType.html",
                            "children":[]
                        }
                    ]
                },
                {
                    "path" : "4",
                    "title":"个人中心",
                    "icon" : 'fa-dashboard',
                    "children" : [
                        {
                            "path":"/4-1",
                            "title":"修改密码",
                            "linkUrl":"modifyPassword.html",
                            "children":[]
                        },
                    ]

                },

            ]
        },
        created() {
            if (localStorage.getItem("user") == null) {
                location.href="/backend/page/Login.html"
            }
            const userName = localStorage.getItem("user")
            if (userName) {
                this.userName = JSON.parse(userName)
            }
        },
        methods:{

            handleUpdate(row) {
                alert(row.date);
            },
            handleDelete(row){
                alert(row.date);
            },
            loginout() {
                localStorage.removeItem("user")
                location.href='Login.html'
                axios.get("/user/logout").then( res => {
                    if (res.data.flag) {
                        this.$message.success("退出成功")
                    }else {
                        this.$message.error("退出失败")
                    }
                })
            }
        }
    })
</script>
</body>
</html>